/*
 * @author: sanbao
 * @Date: 2022-07-26 16:15:45
 */
/**
 * 回获取数据
 */
import request from "@/utils/request"
const getcategorieslist = () => {
    // http://47.108.251.106:8881/api/private/v1/categories
    return request({
        url: 'categories',
        method: 'GET',
    })
}
/**
 * 
 * @param id 
 * @returns 
 */
const getattributeslist = (id: any, state: string) => {
    // http://47.108.251.106:8881/api/private/v1/categories/74/attributes?sel=many
    return request({
        url: `categories/${id}/attributes?sel=${state}`,
        method: 'GET',
    })
}
/**
 * 
 * @param PUTid 
 * @param id 
 * @param data 
 * @returns 
 */
const PUTattributes = (PUTid: number, id: number, data: any) => {
    // http://47.108.251.106:8881/api/private/v1/categories/92/attributes/3932
    return request({
        url: `categories/${PUTid}/attributes/${id}`,
        method: 'PUT',
        data
    })
}
/**
 * 删除当前行
 * @returns 
 */
const deleteattributeslist = (DELETEID: number, id: number) => {
    // http://47.108.251.106:8881/api/private/v1/categories/74/attributes/3936
    return request({
        url: `categories/${DELETEID}/attributes/${id}`,
        method: 'DELETE',
    })
}
/**
 * 添加
 * @param rowID 
 * @param data 
 * @returns 
 */
const addparamslist = (rowID: number, data: any) => {
    // http://47.108.251.106:8881/api/private/v1/categories/74/attributes
    return request({
        url: `categories/${rowID}/attributes`,
        method: 'POST',
        data
    })
}
/**
 * 单个数据查询
 * @param rowID 
 * @param id 
 * @param state 
 * @returns 
 */
const findparamslist = (rowID: number, id: number, state: string) => {
    // http://47.108.251.106:8881/api/private/v1/categories/74/attributes/3998?attr_sel=many
    return request({
        url: `categories/${rowID}/attributes/${id}?attr_sel=${state}`,
        method: 'GET',
    })
}
//
const deitparamslist = (rowID: number, id: number, data: any) => {
    // http://47.108.251.106:8881/api/private/v1/categories/74/attributes/3998
    return request({
        url: `categories/${rowID}/attributes/${id}`,
        method: 'PUT',
        data: { attr_name: data.attr_name, attr_sel: data.attr_sel }
    })
}
export default {
    getcategorieslist,
    getattributeslist,
    PUTattributes,
    deleteattributeslist,
    addparamslist,
    findparamslist,
    deitparamslist
}